<?php
session_start();
require_once('../includes/user.php');
$user=new User();
$quiz_res=$user->query("select * from quiz_names where quiz_id = '$_POST[id]'");
$quiz_row=mysql_fetch_array($quiz_res);
$n_attn_res=$user->query('select pts from limitations where id=1');
$n_attn_row=mysql_fetch_array($n_attn_res);
$user->updateQuizHistory($_SESSION['id'],$_POST['id'],"Interrupted",$n_attn_row['pts']);
$dur=explode(':',$quiz_row['duration']);
$timer=($dur[0]*3600)+($dur[1]*60)+$dur[2];
$res=$user->getQuestion($_POST['id']);
 ?>
<table width="571" height="44" align="center" cellpadding="0" cellspacing="0">
<tr>
	<td height="35" colspan="5" align="right" valign="middle"><div class="must" id="timer">
	  Time left : <?php
	  	if($quiz_row['duration']!='Nill')
		{ 
	   echo $dur[0]; ?> Hours <?php echo $dur[1]; ?> Minutes <?php echo $dur[2]; ?> Seconds<?php }else{
	   echo 'Unlimited'; }?></div></td>
<tr>
<?php
$cnt=1;
while($row=mysql_fetch_array($res))
{
	if($quiz_row['quiz_type']==2)
	{
?>
  <tr>
    <td height="35" colspan="5" align="left" valign="middle"><?php echo '<span class="head">'.$cnt.' .</span>'.$row['ques']; ?></td>
  </tr>
  <tr>
    <td width="41" height="35" align="right">&nbsp;</td>
    <td width="132" height="35" align="left" valign="middle"><input type="radio" id="<?php echo $row['id']; ?>_1" value="1" name="<?php echo $row['id']; ?>"/>
<?php echo $row['op1']; ?></td>
    <td width="136" height="35" align="left" valign="middle"><input type="radio" value="2" id="<?php echo $row['id']; ?>_2" name="<?php echo $row['id']; ?>"/>
<?php echo $row['op2']; ?></td>
    <td width="148" height="35" align="left" valign="middle"><input type="radio" value="3" id="<?php echo $row['id']; ?>_3" name="<?php echo $row['id']; ?>"/>
<?php echo $row['op3']; ?></td>
    <td width="143" height="35" align="left" valign="middle"><input type="radio" value="4" id="<?php echo $row['id']; ?>_4" name="<?php echo $row['id']; ?>"/>
<?php echo $row['op4']; ?></td>
  </tr>
<?php
	}
	elseif($quiz_row['quiz_type']==1)
	{
	?>
    <tr>
    <td height="35" colspan="5" align="left" valign="middle"><?php echo '<span class="head">'.$cnt.' .</span>'.$row['ques']; ?></td>
  </tr>
  <tr>
    <td width="41" height="35" align="right">&nbsp;</td>
    <td width="132" height="35" align="left" valign="middle"><input type="radio" value="1" name="<?php echo $row['id']; ?>" id="<?php echo $row['id']; ?>_1"/>
True</td>
    <td width="136" height="35" align="left" valign="middle"><input type="radio" value="2" name="<?php echo $row['id']; ?>" id="<?php echo $row['id']; ?>_2"/>
False</td>
<td width="143" height="35" align="left" valign="middle"></td>
<td width="143" height="35" align="left" valign="middle"></td>
  </tr>
    <?php
	}
	else if($quiz_row['quiz_type']==3)
	{
	?>
    <tr>
      <td height="35" colspan="5" align="left" valign="middle"><?php echo '<span class="head">'.$cnt.' .</span>'.$row['ques']; ?></td>
    </tr>
    <tr>
    <td height="35" colspan="5" align="left" valign="middle"><textarea cols="70" rows="5" name="<?php echo $row['id']; ?>" id="<?php echo $row['id']; ?>"></textarea></td>
  </tr>
    <?php
	}
$qb_ref.=$row['id'].':';
$cnt++;
}
?>
<tr>
	<td height="35" colspan="5" align="center" valign="middle">  <input type="hidden" name="q_id" id="q_id" value="<?php echo $_POST['id']; ?>" />
	  <input type="hidden" name="q_type" id="q_type" value="<?php echo $quiz_row['quiz_type']; ?>" />
    <input type="hidden" name="post_data" id="post_data" value="<?php echo $qb_ref; ?>" /> <input type="image" name="submit" id="submit" src="img/buttons/submit.gif" onclick="<?php 	if($quiz_row['duration']!='Nill')
	{ ?>updateAnswers()<?php }else{ echo 'verifyAnswers()';} ?>" /></td>
</tr>
</table>
<?php
	if($quiz_row['duration']!='Nill')
	{ 
?>
<script>
$('#timer').ready(function(){
display_timer(<?php echo $timer; ?>);});
</script>
<?php
	}
?>